Another potentially interesting question we can try to answer is how much face representation we see across the task. In order to do so, we’ve trained a linear SVM classifier within subjects on the data from the smoothed FFA localizer to classify signal into faces, objects and scrambles. We can then apply that classifier to various facets of our data. For each of these analyses, we will look at the probability of the classifier predicting a face. If the classifier does indeed predict a face, we score that TR with a “1”, otherwise, it gets a “0”, meaning chance becomes 1/3 = .33.

First, we will apply it to each TR of individual trials. Trials are split into 4 bins based on accuracy and load, and averaged over those measures to create a single time course for each category. The classifier was also applied to each TR of a “template” for each condition. In this analysis, all trials in a given condition were averaged to create a prototypical example for the category. The classifier was then applied to those averages.

We can then look at the probability of classification across subjects. First, we look at it across all subjects, but then we can look at it across our working memory capacity groups.

Finally, we will relate these neural measures to behavior, both averaged over time and for each TR.

library(reshape2)
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────────────────────────────────────────────────────── tidyverse 1.3.0 ──
## ✓ ggplot2 3.3.2     ✓ purrr   0.3.4
## ✓ tibble  3.0.3     ✓ dplyr   1.0.1
## ✓ tidyr   1.1.1     ✓ stringr 1.4.0
## ✓ readr   1.3.1     ✓ forcats 0.5.0
## ── Conflicts ────────────────────────────────────────────────────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(patchwork)

load('data/behav.RData')
load('data/split_groups_info.RData')
load('data/DFR_split_groups_info.RData')

source("helper_fxns/split_into_groups.R")
source('helper_fxns/prep_trial_levels_for_plot.R')
source("helper_fxns/split_trial_type.R")

se <- function(x) {
  sd(x,na.rm=TRUE)/sqrt(length(x[!is.na(x)])) 
}
#classifier information
clf_acc <- read.csv('data/MVPA/DFR_mask_csvs/clf_acc.csv')
best_c <- read.csv('data/MVPA/DFR_mask_csvs/best_C.csv')

# averaages from template 
averages_from_template <- list(high_correct = read.csv('data/MVPA/DFR_mask_csvs/all_suj_high_correct_avg.csv',header=FALSE), 
                               high_incorrect = read.csv('data/MVPA/DFR_mask_csvs/all_suj_high_incorrect_avg.csv',header=FALSE), 
                               low_correct = read.csv('data/MVPA/DFR_mask_csvs/all_suj_low_correct_avg.csv',header=FALSE), 
                               low_incorrect = read.csv('data/MVPA/DFR_mask_csvs/all_suj_low_incorrect_avg.csv',header=FALSE))

averages_from_template[["high_load_correct_diff"]] <- averages_from_template[["high_correct"]][,1:14] - averages_from_template[["high_incorrect"]][,1:14]
averages_from_template[["low_load_correct_diff"]] <- averages_from_template[["low_correct"]][,1:14] - averages_from_template[["low_incorrect"]][,1:14]



# averages from individual trials
individual_trial_averages_probs <- list(
  high_correct = read.csv('data/MVPA/DFR_mask_csvs/all_suj_high_correct_indiv_trial_avg_probs.csv',header=FALSE),
  high_incorrect = read.csv('data/MVPA/DFR_mask_csvs/all_suj_high_incorrect_indiv_trial_avg_probs.csv',header=FALSE),
  low_correct = read.csv('data/MVPA/DFR_mask_csvs/all_suj_low_correct_indiv_trial_avg_probs.csv',header=FALSE),
  low_incorrect = read.csv('data/MVPA/DFR_mask_csvs/all_suj_low_incorrect_indiv_trial_avg_probs.csv',header=FALSE)) 

individual_trial_averages_probs[["high_load_correct_diff"]] <- individual_trial_averages_probs[["high_correct"]][,1:14] - individual_trial_averages_probs[["high_incorrect"]][,1:14]
individual_trial_averages_probs[["low_load_correct_diff"]] <- individual_trial_averages_probs[["low_correct"]][,1:14] - individual_trial_averages_probs[["low_incorrect"]][,1:14]


# averages from individual trials
individual_trial_averages_preds <- list(
  high_correct = read.csv('data/MVPA/DFR_mask_csvs/all_suj_high_correct_indiv_trial_avg_preds.csv',header=FALSE),
  high_incorrect = read.csv('data/MVPA/DFR_mask_csvs/all_suj_high_incorrect_indiv_trial_avg_preds.csv',header=FALSE),
  low_correct = read.csv('data/MVPA/DFR_mask_csvs/all_suj_low_correct_indiv_trial_avg_preds.csv',header=FALSE),
  low_incorrect = read.csv('data/MVPA/DFR_mask_csvs/all_suj_low_incorrect_indiv_trial_avg_preds.csv',header=FALSE)) 

individual_trial_averages_preds[["high_load_correct_diff"]] <- individual_trial_averages_preds[["high_correct"]][,1:14] - individual_trial_averages_preds[["high_incorrect"]][,1:14]

individual_trial_averages_preds[["low_load_correct_diff"]] <- individual_trial_averages_preds[["low_correct"]][,1:14] - individual_trial_averages_preds[["low_incorrect"]][,1:14]


# replace NaNs with NA, add in PTID  

for (i in seq.int(1,6)){
  for (ii in seq.int(1,14)){
    averages_from_template[[i]][is.nan(averages_from_template[[i]][,ii]),ii] <- NA
    individual_trial_averages_probs[[i]][is.nan(individual_trial_averages_probs[[i]][,ii]),ii] <- NA
    individual_trial_averages_preds[[i]][is.nan(individual_trial_averages_preds[[i]][,ii]),ii] <- NA
    
  }
  averages_from_template[[i]]$PTID <- constructs_fMRI$PTID
  individual_trial_averages_probs[[i]]$PTID <- constructs_fMRI$PTID
  individual_trial_averages_preds[[i]]$PTID <- constructs_fMRI$PTID
  
}

save(list=c("clf_acc", "best_c", "averages_from_template", "individual_trial_averages_probs","individual_trial_averages_preds"), file = "data/MVPA_DFR_delay_mask.RData")

Probability of classifying faces

On average, we were able to classify faces with 65.7% accuracy (statistically significantly different from chance = 0.33). The classifier was trained on data from an independent FFA localizer. Data was masked derived from the high > low load contrast during the DFR task - that is, regions that are sensitive to load during the delay period. From that mask, the top 100 voxels based on the faces vs objects contrast in the overall subject GLM were selected as features for the classifier. The data used to train the classifier were shifted by 4.5 seconds to account for the hemodynamic delay.

A linear SVM classifer was used; the localizer task was split into 6 blocks of stimuli. These blocks were used in a pre-defined split for cross validation, where one block of each stimulus type was held out as a test set. Data were normalized within the training and test sets separately. Within this training set, another cross validation process was repeated to tune the cost of the model over the values [0.01, 0.1, 1, 10]. The best value of the cost function was used for each cross validation to score the classifier on the test set. The best classifer was also used to predict face presence at each TR during the DFR task.

clf_acc$average <- rowMeans(clf_acc)
t.test(clf_acc$average,mu=0.33)
## 
##  One Sample t-test
## 
## data:  clf_acc$average
## t = 37.25, df = 169, p-value < 2.2e-16
## alternative hypothesis: true mean is not equal to 0.33
## 95 percent confidence interval:
##  0.6398232 0.6745000
## sample estimates:
## mean of x 
## 0.6571616
template_preds_melt <- prep_trial_levels_for_plot(averages_from_template)
## Using level as id variables
individual_trial_probs_melt <- prep_trial_levels_for_plot(individual_trial_averages_probs)
## Using level as id variables
individual_trial_preds_melt <- prep_trial_levels_for_plot(individual_trial_averages_preds)
## Using level as id variables

All subjects

The shape of the time course is different here than it was for the fusiform region - here, we’re well below chance for encoding, but start to see a significant probability during delay (starting around TR 8) and the probe.

From individual trials

During delay period, there is no difference in probability of classifying face across laod, but we do see significantly higher probability of classifying a face in correct vs incorrect trials.

ggplot(data=individual_trial_probs_melt %>% filter(level %in% c("high_correct", "high_incorrect", "low_correct", "low_incorrect")),aes(x=TR,y=value))+
  geom_line(aes(color=level))+
  geom_line(aes(x=TR,y=0.33),color="black",linetype="dotted")+
  geom_ribbon(aes(x=TR,ymin=se_min,ymax=se_max,fill=level),alpha=0.2)+
  scale_x_continuous(breaks = c(1:14),labels=c(1:14))+
  ylab("Probability of classifier predicting a face")+
  theme_classic()

delay_level_avg <- data.frame(high = rowMeans(cbind(individual_trial_averages_probs[["high_correct"]]$V8, individual_trial_averages_probs[["high_incorrect"]]$V8), na.rm=TRUE), low = rowMeans(cbind(individual_trial_averages_probs[["low_correct"]]$V8, individual_trial_averages_probs[["low_incorrect"]]$V8),na.rm=TRUE))

t.test(delay_level_avg$high,delay_level_avg$low,paired=TRUE)
## 
##  Paired t-test
## 
## data:  delay_level_avg$high and delay_level_avg$low
## t = -1.8136, df = 169, p-value = 0.07152
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.057361357  0.002431357
## sample estimates:
## mean of the differences 
##               -0.027465
delay_acc_avg <- data.frame(correct = rowMeans(cbind(individual_trial_averages_probs[["high_correct"]]$V8, individual_trial_averages_probs[["low_correct"]]$V8), na.rm=TRUE), incorrect = rowMeans(cbind(individual_trial_averages_probs[["low_incorrect"]]$V8, individual_trial_averages_probs[["high_incorrect"]]$V8),na.rm=TRUE))

t.test(delay_acc_avg$correct,delay_acc_avg$incorrect,paired=TRUE)
## 
##  Paired t-test
## 
## data:  delay_acc_avg$correct and delay_acc_avg$incorrect
## t = 2.9832, df = 169, p-value = 0.003275
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  0.01358658 0.06674342
## sample estimates:
## mean of the differences 
##                0.040165

In this mask, we see pretty much always a larger probability of classifying a face from correct trials, but not much difference between low and high loads.

ggplot(data=individual_trial_probs_melt %>% filter(level %in% c("low_load_correct_diff","high_load_correct_diff")),aes(x=TR,y=value))+
  geom_line(aes(x=TR,y=0), linetype="dotted")+
  geom_line(aes(color=level))+
  geom_ribbon(aes(x=TR,ymin=se_min,ymax=se_max,fill=level),alpha=0.2)+
  scale_x_continuous(breaks = c(1:14),labels=c(1:14))+
  ylab("Correct - Incorrect Diff in Probability of Classifying Faces")+
  theme_classic()

From templates

In the templates, we see a similar structure as in the individual trials. However, instead of seeing differences in load (like we saw in the fusiform data), we see a difference in accuracy, where there is higher probability of being able to classify a face from delay and probe periods in correct trials (regardless of load) than incorrect trials.

ggplot(data=template_preds_melt%>% filter(level %in% c("high_correct", "high_incorrect", "low_correct", "low_incorrect")),aes(x=TR,y=value))+
  geom_line(aes(color=level))+
  geom_line(aes(x=TR,y=0.33),color="black",linetype="dotted")+
  geom_ribbon(aes(x=TR,ymin=se_min,ymax=se_max,fill=level),alpha=0.2)+
  scale_x_continuous(breaks = c(1:14),labels=c(1:14))+
  ylab("Probability of classifier predicting a face")+
  theme_classic()

acc_data_delay <- data.frame(correct = rowMeans(cbind(averages_from_template[["high_correct"]]$V8,averages_from_template[["low_correct"]]$V8)), incorrect = averages_from_template[["high_incorrect"]]$V8)
t.test(acc_data_delay$correct,acc_data_delay$incorrect, paired=TRUE)
## 
##  Paired t-test
## 
## data:  acc_data_delay$correct and acc_data_delay$incorrect
## t = 3.2889, df = 169, p-value = 0.001224
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  0.03723366 0.14903869
## sample estimates:
## mean of the differences 
##              0.09313618
acc_data_probe <- data.frame(correct = rowMeans(cbind(averages_from_template[["high_correct"]]$V10,averages_from_template[["low_correct"]]$V10)), incorrect = averages_from_template[["high_incorrect"]]$V10)
t.test(acc_data_probe$correct,acc_data_probe$incorrect, paired=TRUE)
## 
##  Paired t-test
## 
## data:  acc_data_probe$correct and acc_data_probe$incorrect
## t = 2.6799, df = 169, p-value = 0.008093
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  0.02233467 0.14727416
## sample estimates:
## mean of the differences 
##              0.08480441
probe_data_template <- data.frame(high_correct=averages_from_template[["high_correct"]]$V10, high_incorrect = averages_from_template[["high_incorrect"]]$V10, low_correct = averages_from_template[["low_correct"]]$V10)
probe_data_template <- melt(probe_data_template)
## No id variables; using all as measure variables
probe.aov <- aov(value ~ variable, data = probe_data_template)
summary(probe.aov)
##              Df Sum Sq Mean Sq F value Pr(>F)  
## variable      2   0.85  0.4255   2.612 0.0744 .
## Residuals   507  82.61  0.1629                 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
TukeyHSD(probe.aov)
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = value ~ variable, data = probe_data_template)
## 
## $variable
##                                    diff         lwr         upr     p adj
## high_incorrect-high_correct -0.09509824 -0.19801529 0.007818818 0.0770123
## low_correct-high_correct    -0.02058765 -0.12350470 0.082329406 0.8853111
## low_correct-high_incorrect   0.07451059 -0.02840647 0.177427642 0.2054811

I’m not 100% sure this is statistically valid, but the average prediction is higher for the predictions from template vs predictions from the individual trials.

compare_across_temp_indiv <- data.frame(template = rowMeans(cbind(averages_from_template[["high_correct"]]$V10,
                                                                  averages_from_template[["high_incorrect"]]$V10,
                                                                  averages_from_template[["low_correct"]]$V10)),
                                        indiv = rowMeans(cbind(individual_trial_averages_probs[["high_correct"]]$V10,
                                                               individual_trial_averages_probs[["high_incorrect"]]$V10,
                                                               individual_trial_averages_probs[["low_correct"]]$V10)))

wilcox.test(compare_across_temp_indiv$template, compare_across_temp_indiv$indiv,paired=TRUE)
## 
##  Wilcoxon signed rank test with continuity correction
## 
## data:  compare_across_temp_indiv$template and compare_across_temp_indiv$indiv
## V = 11922, p-value = 4.41e-13
## alternative hypothesis: true location shift is not equal to 0
ggplot(data=template_preds_melt %>% filter(level %in% c("low_load_correct_diff","high_load_correct_diff")),aes(x=TR,y=value))+
  geom_line(aes(color=level))+
  geom_ribbon(aes(x=TR,ymin=se_min,ymax=se_max,fill=level),alpha=0.2)+
  scale_x_continuous(breaks = c(1:14),labels=c(1:14))+
  ylab("Correct - Incorrect Diff in Probability of Classifying Faces")+
  theme_classic()

By Working Memory Capacity Groups

split_template <- split_trial_type(averages_from_template,WM_groups)
split_indiv_probs <- split_trial_type(individual_trial_averages_probs, WM_groups)

From Indiv Trials

The only difference across group is in the low incorrect trials during delay period, where medium capacity subjects have greater probability of classifying than low capacity subjects. However, this result comes with the caveat of all the incorrect trials that there are very few trials and some subjects don’t have any.

indiv_avgs <- list()

for (i in seq.int(1,4)){
  indiv_avgs[[i]] <- ggplot(data = split_indiv_probs[["avgs"]][[i]][["all"]])+
    geom_line(aes(x=TR,y=mean,color=group))+
    geom_ribbon(aes(x=TR,ymin=se_min,ymax=se_max,fill=group),alpha=0.2)+
    geom_line(aes(x=TR,y=0.33),color="black",linetype="dotted")+
    scale_x_continuous(breaks = c(1:14),labels=c(1:14))+
    ggtitle(names(split_indiv_probs[["avgs"]])[i])+
    ylab("Probability")+
    theme_classic()
  
}

(indiv_avgs[[1]] + indiv_avgs[[2]]) / (indiv_avgs[[3]] + indiv_avgs[[4]])+
  plot_layout(guides = "collect")+
  plot_annotation(title="Probability of classifier predicting a face from individual trials")

for (trial_type in seq.int(1,4)){ 
  print(names(split_indiv_probs[["all_data"]])[trial_type])
  temp.aov <- aov(split_indiv_probs[["all_data"]][[trial_type]][["all"]][,8] ~ split_indiv_probs[["all_data"]][[trial_type]][["all"]][,16])
  print(summary(temp.aov))
  print(TukeyHSD(temp.aov))
}
## [1] "high_correct"
##                                                               Df Sum Sq Mean Sq
## split_indiv_probs[["all_data"]][[trial_type]][["all"]][, 16]   2  0.089 0.04466
## Residuals                                                    165  3.175 0.01924
##                                                              F value Pr(>F)
## split_indiv_probs[["all_data"]][[trial_type]][["all"]][, 16]   2.321  0.101
## Residuals                                                                  
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = split_indiv_probs[["all_data"]][[trial_type]][["all"]][, 8] ~ split_indiv_probs[["all_data"]][[trial_type]][["all"]][, 16])
## 
## $`split_indiv_probs[["all_data"]][[trial_type]][["all"]][, 16]`
##                 diff         lwr        upr     p adj
## med-high  0.03795714 -0.02403945 0.09995373 0.3188501
## low-high -0.01723929 -0.07923587 0.04475730 0.7882913
## low-med  -0.05519643 -0.11719302 0.00680016 0.0917871
## 
## [1] "high_incorrect"
##                                                               Df Sum Sq Mean Sq
## split_indiv_probs[["all_data"]][[trial_type]][["all"]][, 16]   2  0.107 0.05358
## Residuals                                                    165  4.960 0.03006
##                                                              F value Pr(>F)
## split_indiv_probs[["all_data"]][[trial_type]][["all"]][, 16]   1.782  0.171
## Residuals                                                                  
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = split_indiv_probs[["all_data"]][[trial_type]][["all"]][, 8] ~ split_indiv_probs[["all_data"]][[trial_type]][["all"]][, 16])
## 
## $`split_indiv_probs[["all_data"]][[trial_type]][["all"]][, 16]`
##                  diff         lwr        upr     p adj
## med-high  0.050039286 -0.02745543 0.12753400 0.2808758
## low-high -0.006483929 -0.08397864 0.07101079 0.9786472
## low-med  -0.056523214 -0.13401793 0.02097150 0.1989223
## 
## [1] "low_correct"
##                                                               Df Sum Sq
## split_indiv_probs[["all_data"]][[trial_type]][["all"]][, 16]   2 0.0178
## Residuals                                                    165 2.3456
##                                                               Mean Sq F value
## split_indiv_probs[["all_data"]][[trial_type]][["all"]][, 16] 0.008889   0.625
## Residuals                                                    0.014216        
##                                                              Pr(>F)
## split_indiv_probs[["all_data"]][[trial_type]][["all"]][, 16]  0.536
## Residuals                                                          
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = split_indiv_probs[["all_data"]][[trial_type]][["all"]][, 8] ~ split_indiv_probs[["all_data"]][[trial_type]][["all"]][, 16])
## 
## $`split_indiv_probs[["all_data"]][[trial_type]][["all"]][, 16]`
##                  diff         lwr        upr     p adj
## med-high  0.009782143 -0.04350844 0.06307272 0.9014022
## low-high -0.015219643 -0.06851022 0.03807094 0.7780911
## low-med  -0.025001786 -0.07829236 0.02828879 0.5095228
## 
## [1] "low_incorrect"
##                                                               Df Sum Sq Mean Sq
## split_indiv_probs[["all_data"]][[trial_type]][["all"]][, 16]   2  0.826  0.4131
## Residuals                                                    108 11.617  0.1076
##                                                              F value Pr(>F)  
## split_indiv_probs[["all_data"]][[trial_type]][["all"]][, 16]    3.84 0.0245 *
## Residuals                                                                    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 57 observations deleted due to missingness
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = split_indiv_probs[["all_data"]][[trial_type]][["all"]][, 8] ~ split_indiv_probs[["all_data"]][[trial_type]][["all"]][, 16])
## 
## $`split_indiv_probs[["all_data"]][[trial_type]][["all"]][, 16]`
##                 diff         lwr         upr     p adj
## med-high  0.13034018 -0.06189001  0.32257038 0.2452468
## low-high -0.07384839 -0.25576996  0.10807319 0.6006993
## low-med  -0.20418857 -0.37984710 -0.02853005 0.0183629

From templates

Similarly, no differences between groups at delay or probe.

template_avgs <- list()

for (i in seq.int(1,4)){
  template_avgs[[i]] <- ggplot(data = split_template[["avgs"]][[i]][["all"]])+
    geom_line(aes(x=TR,y=mean,color=group))+
    geom_ribbon(aes(x=TR,ymin=se_min,ymax=se_max,fill=group),alpha=0.2)+
    geom_line(aes(x=TR,y=0.33),color="black",linetype="dotted")+
    scale_x_continuous(breaks = c(1:14),labels=c(1:14))+
    ggtitle(names(split_template[["avgs"]])[i])+
    ylab("Probability")+
    theme_classic()
  
}

(template_avgs[[1]] + template_avgs[[2]]) / (template_avgs[[3]] + template_avgs[[4]])+
  plot_layout(guides = "collect")+
  plot_annotation(title="Probability of classifier predicting a face from trial templates")

for (trial_type in seq.int(1,4)){ 
  print(names(split_template[["all_data"]])[trial_type])
  temp.aov <- aov(split_template[["all_data"]][[trial_type]][["all"]][,10] ~ split_template[["all_data"]][[trial_type]][["all"]][,16])
  print(summary(temp.aov))
  print(TukeyHSD(temp.aov))
}
## [1] "high_correct"
##                                                            Df Sum Sq Mean Sq
## split_template[["all_data"]][[trial_type]][["all"]][, 16]   2  0.066 0.03323
## Residuals                                                 165 26.393 0.15996
##                                                           F value Pr(>F)
## split_template[["all_data"]][[trial_type]][["all"]][, 16]   0.208  0.813
## Residuals                                                               
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = split_template[["all_data"]][[trial_type]][["all"]][, 10] ~ split_template[["all_data"]][[trial_type]][["all"]][, 16])
## 
## $`split_template[["all_data"]][[trial_type]][["all"]][, 16]`
##                 diff        lwr       upr     p adj
## med-high  0.01487500 -0.1638841 0.1936341 0.9788772
## low-high -0.03274107 -0.2115001 0.1460180 0.9018141
## low-med  -0.04761607 -0.2263751 0.1311430 0.8038559
## 
## [1] "high_incorrect"
##                                                            Df Sum Sq Mean Sq
## split_template[["all_data"]][[trial_type]][["all"]][, 16]   2  0.232  0.1162
## Residuals                                                 165 27.545  0.1669
##                                                           F value Pr(>F)
## split_template[["all_data"]][[trial_type]][["all"]][, 16]   0.696    0.5
## Residuals                                                               
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = split_template[["all_data"]][[trial_type]][["all"]][, 10] ~ split_template[["all_data"]][[trial_type]][["all"]][, 16])
## 
## $`split_template[["all_data"]][[trial_type]][["all"]][, 16]`
##                  diff        lwr       upr     p adj
## med-high -0.077380357 -0.2599968 0.1052361 0.5765504
## low-high -0.080360714 -0.2629772 0.1022557 0.5522918
## low-med  -0.002980357 -0.1855968 0.1796361 0.9991790
## 
## [1] "low_correct"
##                                                            Df Sum Sq Mean Sq
## split_template[["all_data"]][[trial_type]][["all"]][, 16]   2  0.039 0.01934
## Residuals                                                 165 27.987 0.16962
##                                                           F value Pr(>F)
## split_template[["all_data"]][[trial_type]][["all"]][, 16]   0.114  0.892
## Residuals                                                               
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = split_template[["all_data"]][[trial_type]][["all"]][, 10] ~ split_template[["all_data"]][[trial_type]][["all"]][, 16])
## 
## $`split_template[["all_data"]][[trial_type]][["all"]][, 16]`
##                  diff        lwr       upr     p adj
## med-high -0.008932143 -0.1930103 0.1751460 0.9927658
## low-high  0.026780357 -0.1572978 0.2108585 0.9368529
## low-med   0.035712500 -0.1483657 0.2197907 0.8905295
## 
## [1] "low_incorrect"
##                                                            Df Sum Sq Mean Sq
## split_template[["all_data"]][[trial_type]][["all"]][, 16]   2      0       0
## Residuals                                                 108      0       0
##                                                           F value Pr(>F)
## split_template[["all_data"]][[trial_type]][["all"]][, 16]               
## Residuals                                                               
## 57 observations deleted due to missingness
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = split_template[["all_data"]][[trial_type]][["all"]][, 10] ~ split_template[["all_data"]][[trial_type]][["all"]][, 16])
## 
## $`split_template[["all_data"]][[trial_type]][["all"]][, 16]`
##          diff lwr upr p adj
## med-high    0   0   0   NaN
## low-high    0   0   0   NaN
## low-med     0   0   0   NaN

Correlation with Behavior

Individual Trials

Averaged over time

No correlation with behavior when we look averaged over time.

indiv_avg_over_time <- data.frame(high_correct = rowMeans(individual_trial_averages_probs[["high_correct"]][,1:14]),
                                  high_incorrect = rowMeans(individual_trial_averages_probs[["high_incorrect"]][,1:14]),
                                  low_correct = rowMeans(individual_trial_averages_probs[["low_correct"]][,1:14]),
                                  low_incorrect = rowMeans(individual_trial_averages_probs[["low_incorrect"]][,1:14],na.rm=TRUE), 
                                  high_load_diff_correct = rowMeans(individual_trial_averages_probs[["high_load_correct_diff"]][,1:14]),
                                  low_load_diff_correct = rowMeans(individual_trial_averages_probs[["low_load_correct_diff"]][,1:14]))

indiv_avg_over_time[is.na(indiv_avg_over_time)] <- NA 
indiv_avg_over_time <- data.frame(indiv_avg_over_time, omnibus_span = constructs_fMRI$omnibus_span_no_DFR_MRI, PTID = constructs_fMRI$PTID)
indiv_avg_over_time <- merge(indiv_avg_over_time, p200_data[,c("PTID","BPRS_TOT","XDFR_MRI_ACC_L3", "XDFR_MRI_ACC_L1")],by="PTID")


plot_list <- list()

for (i in seq.int(1,6)){
  plot_data <- indiv_avg_over_time[,c(i+1,8:11)]
  colnames(plot_data)[1] <- "prob"
  plot_list[["omnibus"]][[i]] <- ggplot(data = plot_data,aes(x=prob,y=omnibus_span))+
    geom_point()+
    stat_smooth(method="lm")+
    xlab("Probability")+
    ggtitle(colnames(indiv_avg_over_time)[i+1])+
    theme_classic()
  
  plot_list[["DFR_Acc"]][[i]] <- ggplot(data = plot_data,aes(x=prob,y=XDFR_MRI_ACC_L3))+
    geom_point()+
    stat_smooth(method="lm")+
    xlab("Probability")+
    ggtitle(colnames(indiv_avg_over_time)[i+1])+
    theme_classic()
  
  plot_list[["BPRS"]][[i]] <- ggplot(data = plot_data,aes(x=prob,y=BPRS_TOT))+
    geom_point()+
    stat_smooth(method="lm")+
    xlab("Probability")+
    ggtitle(colnames(indiv_avg_over_time)[i+1])+
    theme_classic()
  
}

(plot_list[["omnibus"]][[1]] + plot_list[["omnibus"]][[2]]) /
  (plot_list[["omnibus"]][[3]] + plot_list[["omnibus"]][[4]]) + 
  plot_annotation(title="Correlation of face probability and Omnibus Span")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 57 rows containing non-finite values (stat_smooth).
## Warning: Removed 57 rows containing missing values (geom_point).

(plot_list[["omnibus"]][[5]] + plot_list[["omnibus"]][[6]])+
  plot_annotation(title="Correlation of difference in face probability across correctness and Omnibus Span")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 57 rows containing non-finite values (stat_smooth).

## Warning: Removed 57 rows containing missing values (geom_point).

(plot_list[["DFR_Acc"]][[1]] + plot_list[["DFR_Acc"]][[2]]) /
  (plot_list[["DFR_Acc"]][[3]] + plot_list[["DFR_Acc"]][[4]]) + 
  plot_annotation(title="Correlation of face probability and DFR High Load Accuracy")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 57 rows containing non-finite values (stat_smooth).

## Warning: Removed 57 rows containing missing values (geom_point).

(plot_list[["DFR_Acc"]][[5]] + plot_list[["DFR_Acc"]][[6]])+
  plot_annotation(title="Correlation of difference in face probability across correctness and DFR High Load Accuracy")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 57 rows containing non-finite values (stat_smooth).

## Warning: Removed 57 rows containing missing values (geom_point).

(plot_list[["BPRS"]][[1]] + plot_list[["BPRS"]][[2]]) /
  (plot_list[["BPRS"]][[3]] + plot_list[["BPRS"]][[4]]) + 
  plot_annotation(title="Correlation of face probability and BPRS")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 57 rows containing non-finite values (stat_smooth).

## Warning: Removed 57 rows containing missing values (geom_point).

(plot_list[["BPRS"]][[5]] + plot_list[["BPRS"]][[6]])+
  plot_annotation(title="Correlation of difference in face probability across correctness and BPRS")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 57 rows containing non-finite values (stat_smooth).

## Warning: Removed 57 rows containing missing values (geom_point).

cor.test(indiv_avg_over_time$low_correct, indiv_avg_over_time$omnibus_span)
## 
##  Pearson's product-moment correlation
## 
## data:  indiv_avg_over_time$low_correct and indiv_avg_over_time$omnibus_span
## t = -1.8537, df = 168, p-value = 0.06553
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.2859973  0.0091314
## sample estimates:
##        cor 
## -0.1415774
cor.test(indiv_avg_over_time$high_load_diff_correct, indiv_avg_over_time$omnibus_span)
## 
##  Pearson's product-moment correlation
## 
## data:  indiv_avg_over_time$high_load_diff_correct and indiv_avg_over_time$omnibus_span
## t = -1.6591, df = 168, p-value = 0.09897
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.27227478  0.02400942
## sample estimates:
##        cor 
## -0.1269637
cor.test(indiv_avg_over_time$low_load_diff_correct, indiv_avg_over_time$omnibus_span)
## 
##  Pearson's product-moment correlation
## 
## data:  indiv_avg_over_time$low_load_diff_correct and indiv_avg_over_time$omnibus_span
## t = -1.7069, df = 111, p-value = 0.09064
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.33476598  0.02555871
## sample estimates:
##        cor 
## -0.1599262

All subjects

Across time

If we look at the patterns over time, we can see that BPRS tends to be positively related to classification only in the probe period during the high load trials, but starts to peak earlier in the low load trials. There is most correlation with accuracy during the encoding period. We also see a slight negative correlation with omnibus span during probe, particularly in the correct high load trials.

Next step is to pull out some of these correlations and see if they’re significant.

data_to_plot <- merge(constructs_fMRI,p200_data,by="PTID")
data_to_plot <- merge(data_to_plot,p200_clinical_zscores,by="PTID")

data_to_plot <- data_to_plot[,c(1,7,14,15,41,42)]
data_to_plot$ACC_LE <- data_to_plot$XDFR_MRI_ACC_L3 - data_to_plot$XDFR_MRI_ACC_L1

corr_to_behav_plots <- list()

for (i in seq.int(1,6)){
  measure_by_time <- data.frame(matrix(nrow=4,ncol=14))
  
  for (measure in seq.int(3,6)){
    for (TR in seq.int(1,14)){
      measure_by_time[measure-2,TR] <- cor(data_to_plot[,measure],individual_trial_averages_probs[[i]][,TR],use = "pairwise.complete.obs")
    }
  }
  
  measure_by_time <- data.frame(t(measure_by_time))
  measure_by_time$TR <- seq.int(1,14)
  
  colnames(measure_by_time)[1:4] <- colnames(data_to_plot)[3:6]
  
  melted_measure_by_time <- melt(measure_by_time,id.vars="TR")
  
  corr_to_behav_plots[[names(individual_trial_averages_probs)[i]]] <- ggplot(data=melted_measure_by_time,aes(x=TR,y=value))+
    geom_line(aes(color=variable))+
    scale_x_continuous(breaks = c(1:14),labels=c(1:14))+
    ggtitle(names(individual_trial_averages_probs)[i])+
    theme_classic()
  
}
(corr_to_behav_plots[[1]] + corr_to_behav_plots[[2]]) / (corr_to_behav_plots[[3]] + corr_to_behav_plots[[4]])+
  plot_layout(guides="collect")+
  plot_annotation(title = "Correlation between face classification and behavioral measures")

(corr_to_behav_plots[[5]] + corr_to_behav_plots[[6]])+
  plot_layout(guides="collect")+
  plot_annotation(title = "Correlation between difference across correctness in face classification and behavioral measures")

plot_list <- list()

for(trial_type in seq.int(1,6)){ 
  temp_plot_data <- merge(p200_data, individual_trial_averages_probs[[trial_type]],by="PTID")
  temp_plot_data <- merge(temp_plot_data,constructs_fMRI,by="PTID")
  
  plot_list[["omnibus"]][["cue"]][[trial_type]] <- ggplot(data=temp_plot_data,aes(y=V6,x=omnibus_span_no_DFR_MRI))+
    geom_point()+
    stat_smooth(method="lm")+
    ylab("Probability")+
    ggtitle(names(individual_trial_averages_probs)[trial_type])+
    theme_classic()
  
  plot_list[["omnibus"]][["delay"]][[trial_type]] <- ggplot(data=temp_plot_data,aes(y=V8,x=omnibus_span_no_DFR_MRI))+
    geom_point()+
    stat_smooth(method="lm")+
    ylab("Probability")+
    ggtitle(names(individual_trial_averages_probs)[trial_type])+
    theme_classic()
  
  plot_list[["omnibus"]][["probe"]][[trial_type]] <- ggplot(data=temp_plot_data,aes(y=V11,x=omnibus_span_no_DFR_MRI))+
    geom_point()+
    stat_smooth(method="lm")+
    ylab("Probability")+
    ggtitle(names(individual_trial_averages_probs)[trial_type])+
    theme_classic()
  
  # Acc
  
  plot_list[["L3_Acc"]][["cue"]][[trial_type]] <- ggplot(data=temp_plot_data,aes(y=V6,x=XDFR_MRI_ACC_L3))+
    geom_point()+
    stat_smooth(method="lm")+
    ylab("Probability")+
    ggtitle(names(individual_trial_averages_probs)[trial_type])+
    theme_classic()
  
  plot_list[["L3_Acc"]][["delay"]][[trial_type]] <- ggplot(data=temp_plot_data,aes(y=V8,x=XDFR_MRI_ACC_L3))+
    geom_point()+
    stat_smooth(method="lm")+
    ylab("Probability")+
    ggtitle(names(individual_trial_averages_probs)[trial_type])+
    theme_classic()
  
  plot_list[["L3_Acc"]][["probe"]][[trial_type]] <- ggplot(data=temp_plot_data,aes(y=V11,x=XDFR_MRI_ACC_L3))+
    geom_point()+
    stat_smooth(method="lm")+
    ylab("Probability")+
    ggtitle(names(individual_trial_averages_probs)[trial_type])+
    theme_classic()
  
  # BPRS  
  plot_list[["BPRS"]][["cue"]][[trial_type]] <- ggplot(data=temp_plot_data,aes(y=V6,x=BPRS_TOT))+
    geom_point()+
    stat_smooth(method="lm")+
    ylab("Probability")+
    ggtitle(names(individual_trial_averages_probs)[trial_type])+
    theme_classic()
  
  plot_list[["BPRS"]][["delay"]][[trial_type]] <- ggplot(data=temp_plot_data,aes(y=V8,x=BPRS_TOT))+
    geom_point()+
    stat_smooth(method="lm")+
    ylab("Probability")+
    ggtitle(names(individual_trial_averages_probs)[trial_type])+
    theme_classic()
  
  plot_list[["BPRS"]][["probe"]][[trial_type]] <- ggplot(data=temp_plot_data,aes(y=V11,x=BPRS_TOT))+
    geom_point()+
    stat_smooth(method="lm")+
    ylab("Probability")+
    ggtitle(names(individual_trial_averages_probs)[trial_type])+
    theme_classic()
  
  
}

Encoding

There are no significant relationships with behavior at encoding.

(plot_list[["omnibus"]][["cue"]][[1]] + plot_list[["omnibus"]][["cue"]][[2]]) /  
  (plot_list[["omnibus"]][["cue"]][[3]] + plot_list[["omnibus"]][["cue"]][[4]]) +
  plot_annotation(title = "Omnibus vs Classification at Cue Period")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 57 rows containing non-finite values (stat_smooth).
## Warning: Removed 57 rows containing missing values (geom_point).

(plot_list[["omnibus"]][["cue"]][[5]] + plot_list[["omnibus"]][["cue"]][[6]])  +
  plot_annotation(title = "Omnibus vs Classification at Cue Period")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 57 rows containing non-finite values (stat_smooth).

## Warning: Removed 57 rows containing missing values (geom_point).

(plot_list[["L3_Acc"]][["cue"]][[1]] + plot_list[["L3_Acc"]][["cue"]][[2]]) /  
  (plot_list[["L3_Acc"]][["cue"]][[3]] + plot_list[["L3_Acc"]][["cue"]][[4]]) +
  plot_annotation(title = "L3_Acc vs Classification at Cue Period")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 57 rows containing non-finite values (stat_smooth).

## Warning: Removed 57 rows containing missing values (geom_point).

(plot_list[["L3_Acc"]][["cue"]][[5]] + plot_list[["L3_Acc"]][["cue"]][[6]])  +
  plot_annotation(title = "L3_Acc vs Classification at Cue Period")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 57 rows containing non-finite values (stat_smooth).

## Warning: Removed 57 rows containing missing values (geom_point).

(plot_list[["BPRS"]][["cue"]][[1]] + plot_list[["BPRS"]][["cue"]][[2]]) /  
  (plot_list[["BPRS"]][["cue"]][[3]] + plot_list[["BPRS"]][["cue"]][[4]]) +
  plot_annotation(title = "BPRS vs Classification at Cue Period")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 57 rows containing non-finite values (stat_smooth).

## Warning: Removed 57 rows containing missing values (geom_point).

(plot_list[["BPRS"]][["cue"]][[5]] + plot_list[["BPRS"]][["cue"]][[6]])  +
  plot_annotation(title = "BPRS vs Classification at Cue Period")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 57 rows containing non-finite values (stat_smooth).

## Warning: Removed 57 rows containing missing values (geom_point).

Delay

We see that there is a significant negative relationship between probability of face classification at delay in correct low load trials and BPRS Total score.

(plot_list[["omnibus"]][["delay"]][[1]] + plot_list[["omnibus"]][["delay"]][[2]]) /  
  (plot_list[["omnibus"]][["delay"]][[3]] + plot_list[["omnibus"]][["delay"]][[4]]) +
  plot_annotation(title = "Omnibus vs Classification at delay Period")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 57 rows containing non-finite values (stat_smooth).
## Warning: Removed 57 rows containing missing values (geom_point).

(plot_list[["omnibus"]][["delay"]][[5]] + plot_list[["omnibus"]][["delay"]][[6]])  +
  plot_annotation(title = "Omnibus vs Classification at delay Period")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 57 rows containing non-finite values (stat_smooth).

## Warning: Removed 57 rows containing missing values (geom_point).

(plot_list[["L3_Acc"]][["delay"]][[1]] + plot_list[["L3_Acc"]][["delay"]][[2]]) /  
  (plot_list[["L3_Acc"]][["delay"]][[3]] + plot_list[["L3_Acc"]][["delay"]][[4]]) +
  plot_annotation(title = "L3_Acc vs Classification at delay Period")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 57 rows containing non-finite values (stat_smooth).

## Warning: Removed 57 rows containing missing values (geom_point).

(plot_list[["L3_Acc"]][["delay"]][[5]] + plot_list[["L3_Acc"]][["delay"]][[6]])  +
  plot_annotation(title = "L3_Acc vs Classification at delay Period")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 57 rows containing non-finite values (stat_smooth).

## Warning: Removed 57 rows containing missing values (geom_point).

(plot_list[["BPRS"]][["delay"]][[1]] + plot_list[["BPRS"]][["delay"]][[2]]) /  
  (plot_list[["BPRS"]][["delay"]][[3]] + plot_list[["BPRS"]][["delay"]][[4]]) +
  plot_annotation(title = "BPRS vs Classification at delay Period")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 57 rows containing non-finite values (stat_smooth).

## Warning: Removed 57 rows containing missing values (geom_point).

(plot_list[["BPRS"]][["delay"]][[5]] + plot_list[["BPRS"]][["delay"]][[6]])  +
  plot_annotation(title = "BPRS vs Classification at delay Period")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 57 rows containing non-finite values (stat_smooth).

## Warning: Removed 57 rows containing missing values (geom_point).

cor.test(individual_trial_averages_probs[["low_load_correct_diff"]]$V8,temp_plot_data$omnibus_span_no_DFR_MRI)
## 
##  Pearson's product-moment correlation
## 
## data:  individual_trial_averages_probs[["low_load_correct_diff"]]$V8 and temp_plot_data$omnibus_span_no_DFR_MRI
## t = -1.5907, df = 111, p-value = 0.1145
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.32505593  0.03644426
## sample estimates:
##        cor 
## -0.1492906
cor.test(individual_trial_averages_probs[["low_load_correct_diff"]]$V8,temp_plot_data$XDFR_MRI_ACC_L3)
## 
##  Pearson's product-moment correlation
## 
## data:  individual_trial_averages_probs[["low_load_correct_diff"]]$V8 and temp_plot_data$XDFR_MRI_ACC_L3
## t = -1.0953, df = 111, p-value = 0.2758
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.28273024  0.08291264
## sample estimates:
##        cor 
## -0.1034009
cor.test(individual_trial_averages_probs[["low_correct"]]$V8,temp_plot_data$BPRS_TOT)
## 
##  Pearson's product-moment correlation
## 
## data:  individual_trial_averages_probs[["low_correct"]]$V8 and temp_plot_data$BPRS_TOT
## t = -2.3062, df = 168, p-value = 0.02232
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.31732284 -0.02532881
## sample estimates:
##        cor 
## -0.1751752
cor.test(individual_trial_averages_probs[["high_correct"]]$V8,temp_plot_data$BPRS_TOT)
## 
##  Pearson's product-moment correlation
## 
## data:  individual_trial_averages_probs[["high_correct"]]$V8 and temp_plot_data$BPRS_TOT
## t = -1.0812, df = 168, p-value = 0.2811
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.2307575  0.0682375
## sample estimates:
##         cor 
## -0.08313057

Probe

Probability of classification at correct low load trial is significantly correlated with omnibus span at TR 12 and positively with BPRS at TR 10. Here, we’re looking at the scatter plots from TR 11.

(plot_list[["omnibus"]][["probe"]][[1]] + plot_list[["omnibus"]][["probe"]][[2]]) /  
  (plot_list[["omnibus"]][["probe"]][[3]] + plot_list[["omnibus"]][["probe"]][[4]]) +
  plot_annotation(title = "Omnibus vs Classification at probe Period")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 57 rows containing non-finite values (stat_smooth).
## Warning: Removed 57 rows containing missing values (geom_point).

(plot_list[["omnibus"]][["probe"]][[5]] + plot_list[["omnibus"]][["probe"]][[6]])  +
  plot_annotation(title = "Omnibus vs Classification at probe Period")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 57 rows containing non-finite values (stat_smooth).

## Warning: Removed 57 rows containing missing values (geom_point).

(plot_list[["L3_Acc"]][["probe"]][[1]] + plot_list[["L3_Acc"]][["probe"]][[2]]) /  
  (plot_list[["L3_Acc"]][["probe"]][[3]] + plot_list[["L3_Acc"]][["probe"]][[4]]) +
  plot_annotation(title = "L3_Acc vs Classification at probe Period")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 57 rows containing non-finite values (stat_smooth).

## Warning: Removed 57 rows containing missing values (geom_point).

(plot_list[["L3_Acc"]][["probe"]][[5]] + plot_list[["L3_Acc"]][["probe"]][[6]])  +
  plot_annotation(title = "L3_Acc vs Classification at probe Period")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 57 rows containing non-finite values (stat_smooth).

## Warning: Removed 57 rows containing missing values (geom_point).

(plot_list[["BPRS"]][["probe"]][[1]] + plot_list[["BPRS"]][["probe"]][[2]]) /  
  (plot_list[["BPRS"]][["probe"]][[3]] + plot_list[["BPRS"]][["probe"]][[4]]) +
  plot_annotation(title = "BPRS vs Classification at probe Period")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 57 rows containing non-finite values (stat_smooth).

## Warning: Removed 57 rows containing missing values (geom_point).

(plot_list[["BPRS"]][["probe"]][[5]] + plot_list[["BPRS"]][["probe"]][[6]])  +
  plot_annotation(title = "BPRS vs Classification at probe Period")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 57 rows containing non-finite values (stat_smooth).

## Warning: Removed 57 rows containing missing values (geom_point).

cor.test(individual_trial_averages_probs[["low_correct"]]$V11,temp_plot_data$omnibus_span_no_DFR_MRI)
## 
##  Pearson's product-moment correlation
## 
## data:  individual_trial_averages_probs[["low_correct"]]$V11 and temp_plot_data$omnibus_span_no_DFR_MRI
## t = -1.8457, df = 168, p-value = 0.0667
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.285433725  0.009744965
## sample estimates:
##        cor 
## -0.1409761
cor.test(individual_trial_averages_probs[["low_load_correct_diff"]]$V11,temp_plot_data$omnibus_span_no_DFR_MRI)
## 
##  Pearson's product-moment correlation
## 
## data:  individual_trial_averages_probs[["low_load_correct_diff"]]$V11 and temp_plot_data$omnibus_span_no_DFR_MRI
## t = -1.5369, df = 111, p-value = 0.1272
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.32053325  0.04148533
## sample estimates:
##        cor 
## -0.1443507
cor.test(individual_trial_averages_probs[["low_correct"]]$V11,temp_plot_data$XDFR_MRI_ACC_L3)
## 
##  Pearson's product-moment correlation
## 
## data:  individual_trial_averages_probs[["low_correct"]]$V11 and temp_plot_data$XDFR_MRI_ACC_L3
## t = -1.3584, df = 168, p-value = 0.1762
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.25081025  0.04702116
## sample estimates:
##        cor 
## -0.1042308
cor.test(individual_trial_averages_probs[["high_correct"]]$V11,temp_plot_data$XDFR_MRI_ACC_L3)
## 
##  Pearson's product-moment correlation
## 
## data:  individual_trial_averages_probs[["high_correct"]]$V11 and temp_plot_data$XDFR_MRI_ACC_L3
## t = -1.3061, df = 168, p-value = 0.1933
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.24704776  0.05102257
## sample estimates:
##        cor 
## -0.1002617
cor.test(individual_trial_averages_probs[["high_load_correct_diff"]]$V11,temp_plot_data$XDFR_MRI_ACC_L3)
## 
##  Pearson's product-moment correlation
## 
## data:  individual_trial_averages_probs[["high_load_correct_diff"]]$V11 and temp_plot_data$XDFR_MRI_ACC_L3
## t = -1.8561, df = 168, p-value = 0.06519
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.28616510  0.00894861
## sample estimates:
##        cor 
## -0.1417566
behav_classification_corr_list <- list()

for (trial_type in seq.int(1,6)){ 
  group_corrs_omnibus <- data.frame(matrix(nrow=3,ncol=14))
  rownames(group_corrs_omnibus) <- names(split_indiv_probs[["all_data"]][[trial_type]])[1:3]
  colnames(group_corrs_omnibus) <- seq.int(1,14)
  
  group_corrs_acc <- data.frame(matrix(nrow=3,ncol=14))
  rownames(group_corrs_acc) <- names(split_indiv_probs[["all_data"]][[trial_type]])[1:3]
  colnames(group_corrs_acc) <- seq.int(1,14)
  
  group_corrs_BPRS <- data.frame(matrix(nrow=3,ncol=14))
  rownames(group_corrs_BPRS) <- names(split_indiv_probs[["all_data"]][[trial_type]])[1:3]
  colnames(group_corrs_BPRS) <- seq.int(1,14)
  
  for (level in seq.int(1,3)){ 
    temp_subj <- split_indiv_probs[["all_data"]][[trial_type]][[level]][order(split_indiv_probs[["all_data"]][[trial_type]][[level]]$PTID),]
    temp_data <- data_to_plot[data_to_plot$PTID %in% split_indiv_probs[["all_data"]][[trial_type]][[level]]$PTID,]
    
    for (TR in seq.int(1,14)){
      
      group_corrs_omnibus[level,TR] <- cor(temp_subj[,TR],temp_data$omnibus_span_no_DFR_MRI,use="pairwise.complete.obs")
      group_corrs_acc[level,TR] <- cor(temp_subj[,TR],temp_data$XDFR_MRI_ACC_L3,use="pairwise.complete.obs")
      group_corrs_BPRS[level,TR] <- cor(temp_subj[,TR],temp_data$BPRS_TOT.x,use="pairwise.complete.obs")
      
    }
    group_corrs_acc$level <- factor(rownames(group_corrs_acc))
    group_corrs_BPRS$level <- factor(rownames(group_corrs_acc))
    group_corrs_omnibus$level <- factor(rownames(group_corrs_acc))
    
  }
  
  behav_classification_corr_list[["omnibus"]][[names(split_indiv_probs[["all_data"]])[trial_type]]] <- group_corrs_omnibus
  behav_classification_corr_list[["BPRS"]][[names(split_indiv_probs[["all_data"]])[trial_type]]] <- group_corrs_BPRS
  behav_classification_corr_list[["L3_Acc"]][[names(split_indiv_probs[["all_data"]])[trial_type]]] <- group_corrs_acc
}

By Working Memory Capacity

behav_classification_corr_melt <- list()
behav_split_plot_list <- list()

for (measure in seq.int(1,3)){
  for (trial_type in seq.int(1,6)){ 
    behav_classification_corr_melt[[names(behav_classification_corr_list)[measure]]][[names(behav_classification_corr_list[[measure]])[trial_type]]] <- melt(behav_classification_corr_list[[measure]][[trial_type]],id.vars="level")
    behav_classification_corr_melt[[measure]][[trial_type]]$variable <- as.numeric(as.character(behav_classification_corr_melt[[measure]][[trial_type]]$variable))
    behav_classification_corr_melt[[measure]][[trial_type]]$level <- factor(behav_classification_corr_melt[[measure]][[trial_type]]$level, levels=c("high","med","low"))
    
    behav_split_plot_list[[names(behav_classification_corr_melt)[measure]]][[names(behav_classification_corr_melt[[measure]])[trial_type]]] <- 
      ggplot(data = behav_classification_corr_melt[[measure]][[trial_type]],aes(x=variable,y=value))+
      geom_line(aes(color=level))+
      scale_x_continuous(breaks = c(1:14),labels=c(1:14))+
      ggtitle(names(behav_classification_corr_list[[measure]])[trial_type])+
      xlab("TR")+
      ylab("Correlation")+
      theme_classic()
    
  }
}
(behav_split_plot_list[["omnibus"]][[1]] + behav_split_plot_list[["omnibus"]][[2]]) / 
  (behav_split_plot_list[["omnibus"]][[3]] + behav_split_plot_list[["omnibus"]][[4]])+
  plot_annotation("Omnibus Span Correlation with Face Classification Probability by Group")+
  plot_layout(guides="collect")

(behav_split_plot_list[["omnibus"]][[5]] + behav_split_plot_list[["omnibus"]][[6]]) + 
  plot_annotation("Omnibus Span Correlation with Face Classification Probability by Group")+
  plot_layout(guides="collect")

(behav_split_plot_list[["L3_Acc"]][[1]] + behav_split_plot_list[["L3_Acc"]][[2]]) / 
  (behav_split_plot_list[["L3_Acc"]][[3]] + behav_split_plot_list[["L3_Acc"]][[4]])+
  plot_annotation("High Load Acc Correlation with Face Classification Probability by Group")+
  plot_layout(guides="collect")

(behav_split_plot_list[["L3_Acc"]][[5]] + behav_split_plot_list[["L3_Acc"]][[6]]) +
  plot_annotation("High Load Acc Correlation with Face Classification Probability by Group")+
  plot_layout(guides="collect")

(behav_split_plot_list[["BPRS"]][[1]] + behav_split_plot_list[["BPRS"]][[2]]) / 
  (behav_split_plot_list[["BPRS"]][[3]] + behav_split_plot_list[["BPRS"]][[4]])+
  plot_annotation("BPRS Total Correlation with Face Classification Probability by Group")+
  plot_layout(guides="collect")

(behav_split_plot_list[["BPRS"]][[5]] + behav_split_plot_list[["BPRS"]][[6]]) +
  plot_annotation("BPRS Total Correlation with Face Classification Probability by Group")+
  plot_layout(guides="collect")

Template

Averaged over time

If we see a strong relationship between the difference between correct and incorrect trials at low load.

template_avg_over_time <- data.frame(high_correct = rowMeans(averages_from_template[["high_correct"]][,1:14]),
                                     high_incorrect = rowMeans(averages_from_template[["high_incorrect"]][,1:14]),
                                     low_correct = rowMeans(averages_from_template[["low_correct"]][,1:14]),
                                     low_incorrect = rowMeans(averages_from_template[["low_incorrect"]][,1:14],na.rm=TRUE), 
                                     high_load_diff_correct = rowMeans(averages_from_template[["high_load_correct_diff"]][,1:14]),
                                     low_load_diff_correct = rowMeans(averages_from_template[["low_load_correct_diff"]][,1:14]))

template_avg_over_time[is.na(template_avg_over_time)] <- NA 
template_avg_over_time <- data.frame(template_avg_over_time, omnibus_span = constructs_fMRI$omnibus_span_no_DFR_MRI, PTID = constructs_fMRI$PTID)
template_avg_over_time <- merge(template_avg_over_time, p200_data[,c("PTID","BPRS_TOT","XDFR_MRI_ACC_L3", "XDFR_MRI_ACC_L1")],by="PTID")


plot_list <- list()

for (i in seq.int(1,6)){
  plot_data <- template_avg_over_time[,c(i+1,8:11)]
  colnames(plot_data)[1] <- "prob"
  plot_list[["omnibus"]][[i]] <- ggplot(data = plot_data,aes(x=prob,y=omnibus_span))+
    geom_point()+
    stat_smooth(method="lm")+
    xlab("Probability")+
    ggtitle(colnames(template_avg_over_time)[i+1])+
    theme_classic()
  
  plot_list[["DFR_Acc"]][[i]] <- ggplot(data = plot_data,aes(x=prob,y=XDFR_MRI_ACC_L3))+
    geom_point()+
    stat_smooth(method="lm")+
    xlab("Probability")+
    ggtitle(colnames(template_avg_over_time)[i+1])+
    theme_classic()
  
  plot_list[["BPRS"]][[i]] <- ggplot(data = plot_data,aes(x=prob,y=BPRS_TOT))+
    geom_point()+
    stat_smooth(method="lm")+
    xlab("Probability")+
    ggtitle(colnames(template_avg_over_time)[i+1])+
    theme_classic()
  
}

(plot_list[["omnibus"]][[1]] + plot_list[["omnibus"]][[2]]) /
  (plot_list[["omnibus"]][[3]] + plot_list[["omnibus"]][[4]]) + 
  plot_annotation(title="Correlation of face probability and Omnibus Span")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 57 rows containing non-finite values (stat_smooth).
## Warning: Removed 57 rows containing missing values (geom_point).

(plot_list[["omnibus"]][[5]] + plot_list[["omnibus"]][[6]])+
  plot_annotation(title="Correlation of difference in face probability across correctness and Omnibus Span")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 57 rows containing non-finite values (stat_smooth).

## Warning: Removed 57 rows containing missing values (geom_point).

(plot_list[["DFR_Acc"]][[1]] + plot_list[["DFR_Acc"]][[2]]) /
  (plot_list[["DFR_Acc"]][[3]] + plot_list[["DFR_Acc"]][[4]]) + 
  plot_annotation(title="Correlation of face probability and DFR High Load Accuracy")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 57 rows containing non-finite values (stat_smooth).

## Warning: Removed 57 rows containing missing values (geom_point).

(plot_list[["DFR_Acc"]][[5]] + plot_list[["DFR_Acc"]][[6]])+
  plot_annotation(title="Correlation of difference in face probability across correctness and DFR High Load Accuracy")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 57 rows containing non-finite values (stat_smooth).

## Warning: Removed 57 rows containing missing values (geom_point).

(plot_list[["BPRS"]][[1]] + plot_list[["BPRS"]][[2]]) /
  (plot_list[["BPRS"]][[3]] + plot_list[["BPRS"]][[4]]) + 
  plot_annotation(title="Correlation of face probability and BPRS")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 57 rows containing non-finite values (stat_smooth).

## Warning: Removed 57 rows containing missing values (geom_point).

(plot_list[["BPRS"]][[5]] + plot_list[["BPRS"]][[6]])+
  plot_annotation(title="Correlation of difference in face probability across correctness and BPRS")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 57 rows containing non-finite values (stat_smooth).

## Warning: Removed 57 rows containing missing values (geom_point).

cor.test(template_avg_over_time$low_load_diff_correct, template_avg_over_time$XDFR_MRI_ACC_L3)
## 
##  Pearson's product-moment correlation
## 
## data:  template_avg_over_time$low_load_diff_correct and template_avg_over_time$XDFR_MRI_ACC_L3
## t = 2.9452, df = 111, p-value = 0.003933
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.08891654 0.43244683
## sample estimates:
##       cor 
## 0.2692242

All subjects

Over time

data_to_plot <- merge(constructs_fMRI,p200_data,by="PTID")
data_to_plot <- merge(data_to_plot,p200_clinical_zscores,by="PTID")

data_to_plot <- data_to_plot[,c(1,7,14,15,41,42)]
data_to_plot$ACC_LE <- data_to_plot$XDFR_MRI_ACC_L3 - data_to_plot$XDFR_MRI_ACC_L1

corr_to_behav_plots <- list()


for (i in seq.int(1,6)){
  measure_by_time <- data.frame(matrix(nrow=4,ncol=14))
  
  for (measure in seq.int(3,6)){
    for (TR in seq.int(1,14)){
      measure_by_time[measure-2,TR] <- cor(data_to_plot[,measure],averages_from_template[[i]][,TR],use = "pairwise.complete.obs")
    }
  }
  
  measure_by_time <- data.frame(t(measure_by_time))
  measure_by_time$TR <- seq.int(1,14)
  
  colnames(measure_by_time)[1:4] <- colnames(data_to_plot)[3:6]
  
  melted_measure_by_time <- melt(measure_by_time,id.vars="TR")
  
  corr_to_behav_plots[[names(averages_from_template)[i]]] <- ggplot(data=melted_measure_by_time,aes(x=TR,y=value))+
    geom_line(aes(color=variable))+
    scale_x_continuous(breaks = c(1:14),labels=c(1:14))+
    ggtitle(names(averages_from_template)[i])+
    theme_classic()
  
}
(corr_to_behav_plots[[1]] + corr_to_behav_plots[[2]]) / (corr_to_behav_plots[[3]] + corr_to_behav_plots[[4]])+
  plot_layout(guides="collect")+
  plot_annotation(title = "Correlation between face classification and behavioral measures")
## Warning: Removed 56 row(s) containing missing values (geom_path).

(corr_to_behav_plots[[5]] + corr_to_behav_plots[[6]])+
  plot_layout(guides="collect")+
  plot_annotation(title = "Correlation between face classification and behavioral measures")

plot_list <- list()

for(trial_type in seq.int(1,6)){ 
  temp_plot_data <- merge(p200_data, averages_from_template[[trial_type]],by="PTID")
  temp_plot_data <- merge(temp_plot_data,constructs_fMRI,by="PTID")
  
  plot_list[["omnibus"]][["cue"]][[trial_type]] <- ggplot(data=temp_plot_data,aes(y=V6,x=omnibus_span_no_DFR_MRI))+
    geom_point()+
    stat_smooth(method="lm")+
    ylab("Probability")+
    ggtitle(names(averages_from_template)[trial_type])+
    theme_classic()
  
  plot_list[["omnibus"]][["delay"]][[trial_type]] <- ggplot(data=temp_plot_data,aes(y=V8,x=omnibus_span_no_DFR_MRI))+
    geom_point()+
    stat_smooth(method="lm")+
    ylab("Probability")+
    ggtitle(names(averages_from_template)[trial_type])+
    theme_classic()
  
  plot_list[["omnibus"]][["probe"]][[trial_type]] <- ggplot(data=temp_plot_data,aes(y=V11,x=omnibus_span_no_DFR_MRI))+
    geom_point()+
    stat_smooth(method="lm")+
    ylab("Probability")+
    ggtitle(names(averages_from_template)[trial_type])+
    theme_classic()
  
  # Acc
  
  plot_list[["L3_Acc"]][["cue"]][[trial_type]] <- ggplot(data=temp_plot_data,aes(y=V6,x=XDFR_MRI_ACC_L3))+
    geom_point()+
    stat_smooth(method="lm")+
    ylab("Probability")+
    ggtitle(names(averages_from_template)[trial_type])+
    theme_classic()
  
  plot_list[["L3_Acc"]][["delay"]][[trial_type]] <- ggplot(data=temp_plot_data,aes(y=V8,x=XDFR_MRI_ACC_L3))+
    geom_point()+
    stat_smooth(method="lm")+
    ylab("Probability")+
    ggtitle(names(averages_from_template)[trial_type])+
    theme_classic()
  
  plot_list[["L3_Acc"]][["probe"]][[trial_type]] <- ggplot(data=temp_plot_data,aes(y=V11,x=XDFR_MRI_ACC_L3))+
    geom_point()+
    stat_smooth(method="lm")+
    ylab("Probability")+
    ggtitle(names(averages_from_template)[trial_type])+
    theme_classic()
  
  # BPRS  
  plot_list[["BPRS"]][["cue"]][[trial_type]] <- ggplot(data=temp_plot_data,aes(y=V6,x=BPRS_TOT))+
    geom_point()+
    stat_smooth(method="lm")+
    ylab("Probability")+
    ggtitle(names(averages_from_template)[trial_type])+
    theme_classic()
  
  plot_list[["BPRS"]][["delay"]][[trial_type]] <- ggplot(data=temp_plot_data,aes(y=V8,x=BPRS_TOT))+
    geom_point()+
    stat_smooth(method="lm")+
    ylab("Probability")+
    ggtitle(names(averages_from_template)[trial_type])+
    theme_classic()
  
  plot_list[["BPRS"]][["probe"]][[trial_type]] <- ggplot(data=temp_plot_data,aes(y=V11,x=BPRS_TOT))+
    geom_point()+
    stat_smooth(method="lm")+
    ylab("Probability")+
    ggtitle(names(averages_from_template)[trial_type])+
    theme_classic()
  
  
}

Encoding

(plot_list[["omnibus"]][["cue"]][[1]] + plot_list[["omnibus"]][["cue"]][[2]]) /  
  (plot_list[["omnibus"]][["cue"]][[3]] + plot_list[["omnibus"]][["cue"]][[4]]) +
  plot_annotation(title = "Omnibus vs Classification at Cue Period")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 57 rows containing non-finite values (stat_smooth).
## Warning: Removed 57 rows containing missing values (geom_point).

(plot_list[["omnibus"]][["cue"]][[5]] + plot_list[["omnibus"]][["cue"]][[6]]) +
  plot_annotation(title = "Omnibus vs Classification at Cue Period")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 57 rows containing non-finite values (stat_smooth).

## Warning: Removed 57 rows containing missing values (geom_point).

(plot_list[["L3_Acc"]][["cue"]][[1]] + plot_list[["L3_Acc"]][["cue"]][[2]]) /  
  (plot_list[["L3_Acc"]][["cue"]][[3]] + plot_list[["L3_Acc"]][["cue"]][[4]]) +
  plot_annotation(title = "L3_Acc vs Classification at Cue Period")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 57 rows containing non-finite values (stat_smooth).

## Warning: Removed 57 rows containing missing values (geom_point).

(plot_list[["L3_Acc"]][["cue"]][[5]] + plot_list[["L3_Acc"]][["cue"]][[6]]) +
  plot_annotation(title = "L3_Acc vs Classification at Cue Period")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 57 rows containing non-finite values (stat_smooth).

## Warning: Removed 57 rows containing missing values (geom_point).

(plot_list[["BPRS"]][["cue"]][[1]] + plot_list[["BPRS"]][["cue"]][[2]]) /  
  (plot_list[["BPRS"]][["cue"]][[3]] + plot_list[["BPRS"]][["cue"]][[4]]) +
  plot_annotation(title = "BPRS vs Classification at Cue Period")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 57 rows containing non-finite values (stat_smooth).

## Warning: Removed 57 rows containing missing values (geom_point).

(plot_list[["BPRS"]][["cue"]][[5]] + plot_list[["BPRS"]][["cue"]][[6]]) +
  plot_annotation(title = "BPRS vs Classification at Cue Period")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 57 rows containing non-finite values (stat_smooth).

## Warning: Removed 57 rows containing missing values (geom_point).

Delay

There is a significant relationship between high load accuracy and classification on correct low load trials.

(plot_list[["omnibus"]][["delay"]][[1]] + plot_list[["omnibus"]][["delay"]][[2]]) /  
  (plot_list[["omnibus"]][["delay"]][[3]] + plot_list[["omnibus"]][["delay"]][[4]]) +
  plot_annotation(title = "Omnibus vs Classification at delay Period")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 57 rows containing non-finite values (stat_smooth).
## Warning: Removed 57 rows containing missing values (geom_point).

(plot_list[["omnibus"]][["delay"]][[5]] + plot_list[["omnibus"]][["delay"]][[6]]) +
  plot_annotation(title = "Omnibus vs Classification at delay Period")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 57 rows containing non-finite values (stat_smooth).

## Warning: Removed 57 rows containing missing values (geom_point).

(plot_list[["L3_Acc"]][["delay"]][[1]] + plot_list[["L3_Acc"]][["delay"]][[2]]) /  
  (plot_list[["L3_Acc"]][["delay"]][[3]] + plot_list[["L3_Acc"]][["delay"]][[4]]) +
  plot_annotation(title = "L3_Acc vs Classification at delay Period")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 57 rows containing non-finite values (stat_smooth).

## Warning: Removed 57 rows containing missing values (geom_point).

(plot_list[["L3_Acc"]][["delay"]][[5]] + plot_list[["L3_Acc"]][["delay"]][[6]]) +
  plot_annotation(title = "L3_Acc vs Classification at delay Period")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 57 rows containing non-finite values (stat_smooth).

## Warning: Removed 57 rows containing missing values (geom_point).

(plot_list[["BPRS"]][["delay"]][[1]] + plot_list[["BPRS"]][["delay"]][[2]]) /  
  (plot_list[["BPRS"]][["delay"]][[3]] + plot_list[["BPRS"]][["delay"]][[4]]) +
  plot_annotation(title = "BPRS vs Classification at delay Period")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 57 rows containing non-finite values (stat_smooth).

## Warning: Removed 57 rows containing missing values (geom_point).

(plot_list[["BPRS"]][["delay"]][[5]] + plot_list[["BPRS"]][["delay"]][[6]]) +
  plot_annotation(title = "BPRS vs Classification at delay Period")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 57 rows containing non-finite values (stat_smooth).

## Warning: Removed 57 rows containing missing values (geom_point).

cor.test(averages_from_template[["high_correct"]]$V8,temp_plot_data$omnibus_span_no_DFR_MRI)
## 
##  Pearson's product-moment correlation
## 
## data:  averages_from_template[["high_correct"]]$V8 and temp_plot_data$omnibus_span_no_DFR_MRI
## t = 1.5126, df = 168, p-value = 0.1323
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.03521326  0.26186094
## sample estimates:
##       cor 
## 0.1159154
cor.test(averages_from_template[["high_incorrect"]]$V8,temp_plot_data$omnibus_span_no_DFR_MRI)
## 
##  Pearson's product-moment correlation
## 
## data:  averages_from_template[["high_incorrect"]]$V8 and temp_plot_data$omnibus_span_no_DFR_MRI
## t = -0.5934, df = 168, p-value = 0.5537
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1949068  0.1055063
## sample estimates:
##         cor 
## -0.04573426
cor.test(averages_from_template[["high_correct"]]$V8,temp_plot_data$XDFR_MRI_ACC_L3)
## 
##  Pearson's product-moment correlation
## 
## data:  averages_from_template[["high_correct"]]$V8 and temp_plot_data$XDFR_MRI_ACC_L3
## t = 1.7881, df = 168, p-value = 0.07556
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.01414444  0.28138705
## sample estimates:
##       cor 
## 0.1366608
cor.test(averages_from_template[["low_correct"]]$V8,temp_plot_data$XDFR_MRI_ACC_L3)
## 
##  Pearson's product-moment correlation
## 
## data:  averages_from_template[["low_correct"]]$V8 and temp_plot_data$XDFR_MRI_ACC_L3
## t = 2.2359, df = 168, p-value = 0.02668
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.01998664 0.31250799
## sample estimates:
##       cor 
## 0.1699895

Probe

There is a significant relationship between BPRS and classification in the high correct trials, but I’m not convinced that one isn’t driven by the outlier. If you remove the outlier, the p value raises to just over 0.05.

(plot_list[["omnibus"]][["probe"]][[1]] + plot_list[["omnibus"]][["probe"]][[2]]) /  
  (plot_list[["omnibus"]][["probe"]][[3]] + plot_list[["omnibus"]][["probe"]][[4]]) +
  plot_annotation(title = "Omnibus vs Classification at probe Period")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 57 rows containing non-finite values (stat_smooth).
## Warning: Removed 57 rows containing missing values (geom_point).

(plot_list[["omnibus"]][["probe"]][[5]] + plot_list[["omnibus"]][["probe"]][[6]]) +
  plot_annotation(title = "Omnibus vs Classification at probe Period")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 57 rows containing non-finite values (stat_smooth).

## Warning: Removed 57 rows containing missing values (geom_point).

(plot_list[["L3_Acc"]][["probe"]][[1]] + plot_list[["L3_Acc"]][["probe"]][[2]]) /  
  (plot_list[["L3_Acc"]][["probe"]][[3]] + plot_list[["L3_Acc"]][["probe"]][[4]]) +
  plot_annotation(title = "L3_Acc vs Classification at probe Period")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 57 rows containing non-finite values (stat_smooth).

## Warning: Removed 57 rows containing missing values (geom_point).

(plot_list[["L3_Acc"]][["probe"]][[5]] + plot_list[["L3_Acc"]][["probe"]][[6]]) +
  plot_annotation(title = "L3_Acc vs Classification at probe Period")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 57 rows containing non-finite values (stat_smooth).

## Warning: Removed 57 rows containing missing values (geom_point).

(plot_list[["BPRS"]][["probe"]][[1]] + plot_list[["BPRS"]][["probe"]][[2]]) /  
  (plot_list[["BPRS"]][["probe"]][[3]] + plot_list[["BPRS"]][["probe"]][[4]]) +
  plot_annotation(title = "BPRS vs Classification at probe Period")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 57 rows containing non-finite values (stat_smooth).

## Warning: Removed 57 rows containing missing values (geom_point).

(plot_list[["BPRS"]][["probe"]][[5]] + plot_list[["BPRS"]][["probe"]][[6]]) +
  plot_annotation(title = "BPRS vs Classification at probe Period")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 57 rows containing non-finite values (stat_smooth).

## Warning: Removed 57 rows containing missing values (geom_point).

cor.test(averages_from_template[["low_correct"]]$V11,temp_plot_data$omnibus_span_no_DFR_MRI)
## 
##  Pearson's product-moment correlation
## 
## data:  averages_from_template[["low_correct"]]$V11 and temp_plot_data$omnibus_span_no_DFR_MRI
## t = -1.3761, df = 168, p-value = 0.1706
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.25208009  0.04566853
## sample estimates:
##        cor 
## -0.1055714
cor.test(averages_from_template[["high_correct"]]$V11,temp_plot_data$BPRS_TOT)
## 
##  Pearson's product-moment correlation
## 
## data:  averages_from_template[["high_correct"]]$V11 and temp_plot_data$BPRS_TOT
## t = 2.0214, df = 168, p-value = 0.04482
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.003664772 0.297703536
## sample estimates:
##      cor 
## 0.154094
cor.test(averages_from_template[["high_correct"]]$V11[temp_plot_data$BPRS_TOT < 70],temp_plot_data$BPRS_TOT[temp_plot_data$BPRS_TOT < 70])
## 
##  Pearson's product-moment correlation
## 
## data:  averages_from_template[["high_correct"]]$V11[temp_plot_data$BPRS_TOT < 70] and temp_plot_data$BPRS_TOT[temp_plot_data$BPRS_TOT < 70]
## t = 1.9152, df = 167, p-value = 0.05718
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.004458307  0.291117748
## sample estimates:
##       cor 
## 0.1466004
cor.test(averages_from_template[["high_incorrect"]]$V11,temp_plot_data$BPRS_TOT)
## 
##  Pearson's product-moment correlation
## 
## data:  averages_from_template[["high_incorrect"]]$V11 and temp_plot_data$BPRS_TOT
## t = -0.37075, df = 168, p-value = 0.7113
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1783393  0.1224487
## sample estimates:
##         cor 
## -0.02859252
behav_classification_corr_list <- list()

for (trial_type in seq.int(1,6)){ 
  group_corrs_omnibus <- data.frame(matrix(nrow=3,ncol=14))
  rownames(group_corrs_omnibus) <- names(split_template[["all_data"]][[trial_type]])[1:3]
  colnames(group_corrs_omnibus) <- seq.int(1,14)
  
  group_corrs_acc <- data.frame(matrix(nrow=3,ncol=14))
  rownames(group_corrs_acc) <- names(split_template[["all_data"]][[trial_type]])[1:3]
  colnames(group_corrs_acc) <- seq.int(1,14)
  
  group_corrs_BPRS <- data.frame(matrix(nrow=3,ncol=14))
  rownames(group_corrs_BPRS) <- names(split_template[["all_data"]][[trial_type]])[1:3]
  colnames(group_corrs_BPRS) <- seq.int(1,14)
  
  for (level in seq.int(1,3)){ 
    temp_subj <- split_template[["all_data"]][[trial_type]][[level]][order(split_template[["all_data"]][[trial_type]][[level]]$PTID),]
    temp_data <- data_to_plot[data_to_plot$PTID %in% split_template[["all_data"]][[trial_type]][[level]]$PTID,]
    
    for (TR in seq.int(1,14)){
      
      group_corrs_omnibus[level,TR] <- cor(temp_subj[,TR],temp_data$omnibus_span_no_DFR_MRI,use="pairwise.complete.obs")
      group_corrs_acc[level,TR] <- cor(temp_subj[,TR],temp_data$XDFR_MRI_ACC_L3,use="pairwise.complete.obs")
      group_corrs_BPRS[level,TR] <- cor(temp_subj[,TR],temp_data$BPRS_TOT.x,use="pairwise.complete.obs")
      
    }
    group_corrs_acc$level <- factor(rownames(group_corrs_acc))
    group_corrs_BPRS$level <- factor(rownames(group_corrs_acc))
    group_corrs_omnibus$level <- factor(rownames(group_corrs_acc))
    
  }
  
  behav_classification_corr_list[["omnibus"]][[names(split_template[["all_data"]])[trial_type]]] <- group_corrs_omnibus
  behav_classification_corr_list[["BPRS"]][[names(split_template[["all_data"]])[trial_type]]] <- group_corrs_BPRS
  behav_classification_corr_list[["L3_Acc"]][[names(split_template[["all_data"]])[trial_type]]] <- group_corrs_acc
}

By Working Memory Capacity

behav_classification_corr_melt <- list()
behav_split_plot_list <- list()

for (measure in seq.int(1,3)){
  for (trial_type in seq.int(1,6)){ 
    behav_classification_corr_melt[[names(behav_classification_corr_list)[measure]]][[names(behav_classification_corr_list[[measure]])[trial_type]]] <- melt(behav_classification_corr_list[[measure]][[trial_type]],id.vars="level")
    behav_classification_corr_melt[[measure]][[trial_type]]$variable <- as.numeric(as.character(behav_classification_corr_melt[[measure]][[trial_type]]$variable))
    behav_classification_corr_melt[[measure]][[trial_type]]$level <- factor(behav_classification_corr_melt[[measure]][[trial_type]]$level, levels=c("high","med","low"))
    
    behav_split_plot_list[[names(behav_classification_corr_melt)[measure]]][[names(behav_classification_corr_melt[[measure]])[trial_type]]] <- 
      ggplot(data = behav_classification_corr_melt[[measure]][[trial_type]],aes(x=variable,y=value))+
      geom_line(aes(color=level))+
      scale_x_continuous(breaks = c(1:14),labels=c(1:14))+
      ggtitle(names(behav_classification_corr_list[[measure]])[trial_type])+
      xlab("TR")+
      ylab("Correlation")+
      theme_classic()
    
  }
}
(behav_split_plot_list[["omnibus"]][[1]] + behav_split_plot_list[["omnibus"]][[2]]) / 
  (behav_split_plot_list[["omnibus"]][[3]] + behav_split_plot_list[["omnibus"]][[4]])+
  plot_annotation("Omnibus Span Correlation with Face Classification Probability by Group")+
  plot_layout(guides="collect")
## Warning: Removed 42 row(s) containing missing values (geom_path).

(behav_split_plot_list[["omnibus"]][[5]] + behav_split_plot_list[["omnibus"]][[6]]) + 
  plot_annotation("Omnibus Span Correlation with Face Classification Probability by Group")+
  plot_layout(guides="collect")

(behav_split_plot_list[["L3_Acc"]][[1]] + behav_split_plot_list[["L3_Acc"]][[2]]) / 
  (behav_split_plot_list[["L3_Acc"]][[3]] + behav_split_plot_list[["L3_Acc"]][[4]])+
  plot_annotation("High Load Acc Correlation with Face Classification Probability by Group")+
  plot_layout(guides="collect")
## Warning: Removed 42 row(s) containing missing values (geom_path).

(behav_split_plot_list[["L3_Acc"]][[5]] + behav_split_plot_list[["L3_Acc"]][[6]]) + 
  plot_annotation("High Load Acc Correlation with Face Classification Probability by Group")+
  plot_layout(guides="collect")

(behav_split_plot_list[["BPRS"]][[1]] + behav_split_plot_list[["BPRS"]][[2]]) / 
  (behav_split_plot_list[["BPRS"]][[3]] + behav_split_plot_list[["BPRS"]][[4]])+
  plot_annotation("BPRS Total Correlation with Face Classification Probability by Group")+
  plot_layout(guides="collect")
## Warning: Removed 42 row(s) containing missing values (geom_path).

(behav_split_plot_list[["BPRS"]][[5]] + behav_split_plot_list[["BPRS"]][[6]]) + 
  plot_annotation("BPRS Total with Face Classification Probability by Group")+
  plot_layout(guides="collect")